package redislock.seckill.impl;

import java.util.HashMap;
import java.util.Map;

import redislock.seckill.SeckillCase;

public class SeckillCaseImpl implements SeckillCase{

	public static Map<Long, Long> inventory ;
    static{
        inventory = new HashMap<>();
        inventory.put(10000001L, 5000L);
        inventory.put(10000002L, 5000L);
    }
	@Override
	public void secKill(String userID, Long commidityID) {
		reduceInventory(commidityID);
		
	}
	//模拟秒杀操作，假设认为一个秒杀就是将库存减一
    public Long reduceInventory(Long commodityId){
        inventory.put(commodityId,inventory.get(commodityId) - 1);
        return inventory.get(commodityId);
    }

}
